﻿#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

typedef double Real;
typedef long long MyInt;


typedef struct {
	int n;
	int v[21];
}Data;

typedef struct TContext_s
{
	int n;
	Data d1;
	Data d2;
	Data d3;
}TContext;

TContext context;

void read_d1(Data* d)
{
	scanf("%d", &d->n);
	for (int i = 0; i < d->n; ++i)
		scanf("%d", &d->v[i]);
}

void read_data(TContext* ctx)
{
	read_d1(&ctx->d1);
	read_d1(&ctx->d2);
	ctx->d3.n = 0;
}

int prime(int p)
{
	if (p < 2)
		return 0;
	else if (p < 4)
		return 1;
	else if (p % 2 == 0)
		return 0;
	int p2 = (int)sqrt(p) + 1;
	for (int i = 3; i <= p2; i += 2)
		if (p % i == 0)
			return 0;
	return 1;
}

int find(Data* d, int a)
{
	for (int i = 0; i < d->n; ++i)
		if (a == d->v[i])
			return 1;
	return 0;
}

void dump(Data* d)
{
	printf("%d", d->v[0]);
	for (int i = 1; i < d->n; ++i)
		printf(" %d", d->v[i]);
	printf("\n");
}

void do_task(TContext* ctx)
{
	for (int i = 0; i < ctx->d1.n; ++i)
		if (find(&ctx->d2, ctx->d1.v[i]) == 0 && find(&ctx->d3, ctx->d1.v[i]) == 0)
			ctx->d3.v[ctx->d3.n++] = ctx->d1.v[i];
	for (int i = 0; i < ctx->d2.n; ++i)
		if (find(&ctx->d1, ctx->d2.v[i]) == 0 && find(&ctx->d3, ctx->d2.v[i]) == 0)
			ctx->d3.v[ctx->d3.n++] = ctx->d2.v[i];
	dump(&ctx->d3);
}

void solve(TContext* ctx)
{
	read_data(ctx);
	do_task(ctx);
}

int main()
{
	freopen("D:/Develop/GitRepos/MOOC/浙江大学/数据结构/201906/DataStructure/M2019秋C入门和进阶练习集/7-146.txt", "r", stdin);
	solve(&context);
	return 0;
}
